package com.controller;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author
 * @date 2025-07-29
 * @Description
 */
public class TestServlet extends HttpServlet {

    /**
     * 重写 service 方法 当请求进入是 会调用该方法
     *
     * @param req
     * @param resp
     * @throws ServletException
     * @throws IOException
     */
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("========================");
        req.setAttribute("name", "hsc");
        // 转发
        req.getRequestDispatcher("1.jsp").forward(req, resp);
    }
}
